package com.free.coder.common;

 

 
import javax.servlet.ServletContextEvent;

import org.apache.log4j.Logger;
 
import com.free.coder.log.XFLogger;  
 

public class webListener extends
		org.springframework.web.context.ContextLoaderListener {
	private static Logger log = XFLogger.logger;

	public void contextInitialized(ServletContextEvent event) {
		
		try{
			com.suntek.app.session.AppRegister.registAppEventHadleUrl("/yt/user.jsp");		  
		}catch(Exception ex){
			
		}
		  //AppRegister.registAppEventHadleUrl("http://10.0.0.35:9080/yt/user.jsp");
		  //AppRegister.registAppEventHadleUrl("yt/user.jsp");
		  //AppRegister.registAppEventHadleUrl("frame/cti_work.jsp");
		  //AppRegister.registAppEventHadleUrl("/agent/frame/cti_work.jsp");
		log .info("k2.webListener.super.contextInitialized(event)start------------");
		super.contextInitialized(event);
		log.info("xf.webListener  start------------");

		/*
		try {
			ServletContext sc = event.getServletContext();
			org.springframework.web.context.WebApplicationContext ctx = (org.springframework.web.context.WebApplicationContext) sc
					.getAttribute("org.springframework.web.context.WebApplicationContext.ROOT");
			JdbcTemplateDao dao = (JdbcTemplateDao) ctx
					.getBean("SpringJdbcDao");
			
			
			Hashtable hash = new Hashtable();
			String sql ="select * from dict ";
			List dlist = dao.excuteQuery(sql,new  DictRowMapper());
			for(int i = 0 ;i < dlist.size();i++){
				Dict d = (Dict)dlist.get(i);
				sql ="select * from dictitem where dictid='"+d.getDictid()+"'";
				log.info(d.getDictid());
				List ilist = dao.excuteQuery(sql,new  DictitemRowMapper());
				hash.put(d.getDictid(), ilist);
			}
			
			DorpDownListTag.hash = hash;
			log.info("xf.webListener DorpDownListTag.hash------------"+DorpDownListTag.hash.size());
		} catch (Exception ex) {
			log.error(ex, ex);
		}
		*/
	}

	public void contextDestroyed(ServletContextEvent event) {
		try{
			 com.suntek.app.session.AppRegister.unregistAppEventHadleUrl("/yt/user.jsp");
		}catch(Exception ex){
			
		}
		   
		  //AppRegister.unregistAppEventHadleUrl("http://10.0.0.35:9080/yt/user.jsp");
		  //AppRegister.unregistAppEventHadleUrl("yt/user.jsp");
		 // AppRegister.unregistAppEventHadleUrl("frame/cti_work.jsp");
		  //AppRegister.unregistAppEventHadleUrl("/agent/frame/cti_work.jsp");
		System.gc();
		log
				.info("xf.webListener destory --------------------------------------------------------------------");
		super.contextDestroyed(event);

		System.gc();
	}

	private void processTask() {

	}

}
